package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: UseSatistBean
 * @Desciption: 今日学习统计bean
 * @author: yichaohua
 * @date: 2018-07-20
 */
public class UseSatistBean extends NetBaseBean {

    private List<SatiscTimeBean> satiscTimeBeanList = new ArrayList<SatiscTimeBean>();
    private List<SatiscToyBean> satiscToyBeanList = new ArrayList<SatiscToyBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        JSONArray timeJsonArray = jsonObject.optJSONArray("phone_time");
        if(timeJsonArray != null){
            for (int i = 0;i < timeJsonArray.length();i++){
                JSONObject object = timeJsonArray.optJSONObject(i);
                SatiscTimeBean satiscTimeBean = new SatiscTimeBean();
                satiscTimeBean.initByJson(object);

                satiscTimeBeanList.add(satiscTimeBean);
            }
        }

        JSONObject toyJsonObject = jsonObject.optJSONObject("toy");
        if(toyJsonObject != null){
            JSONArray noReachJsonArray = toyJsonObject.optJSONArray("0");
            if(noReachJsonArray != null){
                for (int i = 0;i < noReachJsonArray.length();i++){
                    JSONObject object = noReachJsonArray.optJSONObject(i);
                    SatiscToyBean satiscToyBean = new SatiscToyBean();
                    satiscToyBean.reachType = 0;
                    satiscToyBean.initByJson(object);

                    satiscToyBeanList.add(satiscToyBean);
                }
            }

            JSONArray reachJsonArray = toyJsonObject.optJSONArray("1");
            if(reachJsonArray != null){
                for (int i = 0;i < reachJsonArray.length();i++){
                    JSONObject object = reachJsonArray.optJSONObject(i);
                    SatiscToyBean satiscToyBean = new SatiscToyBean();
                    satiscToyBean.reachType = 1;
                    satiscToyBean.initByJson(object);

                    satiscToyBeanList.add(satiscToyBean);
                }
            }
        }
    }

    public List<SatiscTimeBean> getSatiscTimeBeanList() {
        return satiscTimeBeanList;
    }

    public void setSatiscTimeBeanList(List<SatiscTimeBean> satiscTimeBeanList) {
        this.satiscTimeBeanList = satiscTimeBeanList;
    }

    public List<SatiscToyBean> getSatiscToyBeanList() {
        return satiscToyBeanList;
    }

    public void setSatiscToyBeanList(List<SatiscToyBean> satiscToyBeanList) {
        this.satiscToyBeanList = satiscToyBeanList;
    }
}
